package 网络编程;

import thread.ServerThread;

import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.*;

public class BSServer {
    public static void main(String[] args) throws Exception{
        System.out.println("--------服务端启动成功--------");
        ServerSocket serverSocket = new ServerSocket(8044);
        ExecutorService pool = new ThreadPoolExecutor(20 * 2, 20 * 2, 0, 
                TimeUnit.SECONDS, new ArrayBlockingQueue<>(8), Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        while (true) {
            Socket socket = serverSocket.accept();
            System.out.println(socket.getRemoteSocketAddress() + " 上线了");
            pool.execute(new ServerThread(socket));
        }
    }
}
